<%@ page language="java" contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<%@ taglib uri="/WEB-INF/tlds/att.tld" prefix="att"%>
<%@include file="/WEB-INF/views/include/head.jsp"%>
<html>
<head>
<meta name="decorator" content="sysDefault" />
<title></title>
<style type="text/css">
div.diagram{
	margin: 20px;
	position: relative;
	background: url('${contextPath}/bpm/agent/process/bpmImage?bpmnDefId=${task.bpmnDefId }&instanceId=${task.instanceId }') no-repeat;
	width: ${diagramDiv['width']+20}px;
	height:${diagramDiv['height']+20}px;
}
</style>
<script type="text/javascript"
	src="${staticPath}/js/bpm/agent/process/form/nested-form.js"></script>
<script type="text/javascript">
	var PATH="${contextPath}";
	var formURL = "${formURL}";
	$(document).ready(function() { 
		 $("#jbxxFrame").attr("src",formURL); 
	});

	/**
	* 功能：给url添加一个当前时间日期数值，使页面不会被缓存。
	*/
	String.prototype.getNewUrl = function() {
		// 如果url中没有参数。
		var time = new Date().getTime();
		var url = this;
		if (url.indexOf("?") == -1) {
		url += "?rand=" + time;
		} else {
		url += "&rand=" + time;
		}
		return url;
	};

	//生成页面Token
	var token = NF.genToken();
	function bpmSubmit(){
		setTimeout(function(){
			$("#form").attr("action", PATH+"/bpm/agent/process/finishTask?token="+token).submit();
		},30);
	}
	function finish_task(){
		if("backToStart" == $("input:radio[name=actionName]:checked").val()){//驳回不用提交表单
			bpmSubmit();
		} else {
			if (NF.validate()) {
				NF.addElement("token",token);
				NF.submit();
				bpmSubmit();
			}
		}
	}

	function selectIcon(){ 
		IconDialog({callback:function(src){ 
			var json=eval(src); 
			//src=[{attid:'10000004495002',url:'/ossp-bpm/sys/att/getthumb?getthumb=10000004495002',name:'JQuery zTree.docx'}]
			$("#fileName").val(json[0].name);
			$("#fileId").val(json[0].attid);
		}});
	}; 

	function IconDialog(conf){
		
		if(!conf) conf={};	  
		var url=PATH+'/sys/att/upload/dialog'; 
		if(conf.params)
			url += "?" + '';
		var dialogWidth=800;
		var dialogHeight=300;
		conf=$.extend({},{dialogWidth:dialogWidth ,dialogHeight:dialogHeight ,help:0,status:0,scroll:0,center:1},conf);
		
		
		var winArgs="dialogWidth="+conf.dialogWidth+"px;dialogHeight="+conf.dialogHeight
			+"px;help=" + conf.help +";status=" + conf.status +";scroll=" + conf.scroll +";center=" +conf.center+";status=No";
		/**
		maxSize 上传文件大小
		maxNumber 上传文件数量
		accept 上传文件类型
		***/
		url+="?maxSize=500000&maxNumber=1&accept=png|gif|jpg|jpeg|doc|xlsx|docx|txt|xls";
		url=url.getNewUrl(); 
		var rtn=window.showModalDialog(url,this,winArgs); 
		if(rtn!=undefined){
		
			if(conf.callback){
				conf.callback.call(this,rtn.srcValue); 
			}
		}
	};
		
</script>
</head>
<body>
	<div class="panel panel-default">
		<div class="col-xs-12 panel-heading">
			<h2 class="panel-title o-v-action">
				<a class="btn btn-primary pull-right" role="button" href="#"
					onclick="finish_task();">完成</a>
			</h2>
		</div>
		<iframe id="hidFrame" name="hidFrame" style="display: none;"></iframe>
		<div class="col-sm-12">
			<ul class="nav nav-tabs" id="myTab">
				<li class="active"><a href="#home" data-toggle="tab">基本信息</a></li>
				<li><a href="#history" data-toggle="tab">流程启动</a></li>
				<li><a href="#diagram" data-toggle="tab">流程图</a></li>
			</ul>
			<div class="tab-content" style="height: 60%; width: 100%">
				<div class="tab-pane active" id="home">
					<iframe id="jbxxFrame" name="jbxxFrame" scrolling="no"
						frameborder="no" width="100%" height="500px"></iframe>
				</div>
				<div class="tab-pane" id="history">
					<c:import url="flowInfo.jsp" />
				</div>
				<div class="tab-pane" id="diagram">
					<div class="container-fluid">
						<div class="col-sm-12">  
							<div> 
								<span class="help-block">流程图</span>
								<div class="diagram">
									${diagramDiv['divStr'] }
								</div>
							</div>
						</div> 
					</div>
				</div>
				<div class="panel-footer"></div>
			</div>
		</div>
	</div>
</body>
</html>